def sumList(list):
    data = 0
    for i in list:
        data = data + i
    return data
def getList(a):
    while True:
        num = input("请输入列表元素，结束输入请按q")
        if num == "q" or num == "Q":
            print("输入完成")
            break
        elif num.isdigit():
            num = int(num)
            a.append(num)
        else:
            print('请输入整数')
    return a


test = []



print(getList(test))
print(sumList(test))